<?php
global $_W, $_GPC;

$id = $_GPC['id'];

if (empty($id)) {
    $input = $_GPC['__input'];
    $input['fields'] = !empty($input['fields']) ? $input['fields'] : array();
    $input['fields'] = serialize($input['fields']);
    $input['params'] = !empty($input['params']) ? $input['params'] : array();
    $input['params'] = serialize($input['params']);
    $input['table'] = !empty($input['table']) ? $input['table'] : 'iwe7_builder_forms_data';
    $input['uniacid'] = $_W['uniacid'];
    pdo_insert('iwe7_builder_forms', $input);
    $input['id'] = pdo_insertid();
    $input['fields'] = unserialize($input['fields']);
    $input['params'] = unserialize($input['params']);
    die(json_encode($input));
} else {
    $input = $_GPC['__input'];
    $input['fields'] = !empty($input['fields']) ? $input['fields'] : array();
    $input['fields'] = serialize($input['fields']);
    $input['params'] = !empty($input['params']) ? $input['params'] : array();
    $input['params'] = serialize($input['params']);
    $input['table'] = !empty($input['table']) ? $input['table'] : 'iwe7_builder_forms_data';
    $input['uniacid'] = $_W['uniacid'];
    pdo_update('iwe7_builder_forms', $input, array('id' => $id));
    $input['id'] = pdo_insertid();
    $input['fields'] = unserialize($input['fields']);
    $input['params'] = unserialize($input['params']);
    die(json_encode($input));
}
